<?php
namespace app\index\controller;
use think\Controller;
use think\Request;
use app\index\model\Investhistory;
class Investment extends Common
{
	/*
	*	查询投资记录接口  (Investment/index)
	*	请求方式 post/get
	*	参数：
		APPkey  
	  	APPid
	    Uid	 
		param(搜索类型)  默认为0(投资中) 1(回款中) 3(已完成)
	*	请求方式 get post
	*	返回格式 json	
		加密方式
		解密方式
	*/
    public function index(Request $request)
    {
    	//接收参数
    	$uid = $request->param("uid");
    	$page = $request->param("page");
    	$status = $request->param("status");
    	if(!isset($status)){
    		$status = 1;
    	}
    	if(!isset($page)){
    		$page = 1;
    	}
        if(!isset($uid)){
        	$arr['status'] = 30001;
        	$arr['msg'] = "参数错误";
        }else{
        	//实例化model
	    	$model = new Investhistory;
	    	$data = $model->show($uid,$page,$status);
	    	if(empty($data)){
	    		$arr['status'] = 201;
	    	}else{
	    		foreach($data as $k=>$v){
	    			$data[$k]['time'] = date("Y-m-d H:i:s",$v['time']);
	    		}
	    		$arr['status'] = 200;
	    	}
	    	$arr['msg'] = "成功";
	    	$arr['data'] = $data;
        }
    	//返回数据
    	echo callback(self::$callback,$arr);
    }
}
